<template>
  <div>
    <el-tabs v-model="activeName" type="card" class="demo-tabs" @tab-click="handleClick">
      <el-tab-pane label="退货预警" name="return110">
        <el-form :model="returnOrderForm" inline>
          <el-form-item label="采购时间：">
            <el-date-picker style="width: 200px" v-model="returnOrdertimes" type="datetimerange"
              start-placeholder="开始时间" value-format="x" end-placeholder="结束时间" time-format="A hh:mm:ss" />
          </el-form-item>
          <el-form-item label="仓库：" style="width: 200px">
            <el-select v-model="returnOrderForm.warehouseId">
              <el-option label="全部" value="0" />
              <el-option :label="item.value" :value="item.key" v-for="item in returnWarehouse" :key="item.key" />
            </el-select>
          </el-form-item>
          <el-form-item label="采购单号：">
            <el-input v-model="returnOrderForm.productPurchaseOrderCode" />
          </el-form-item>
          <el-form-item label="店铺skuid:">
            <el-input v-model="returnOrderForm.shopGoodSkuId" />
          </el-form-item>
          <el-form-item label="采购账号：">
            <el-select v-model="returnOrderForm.purchaseCustomerName">
              <el-option :label="item.value" :value="item.key" v-for="item in createPurchaseCustomerDicTable"
                :key="item.id" />
            </el-select>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="returnSearch">搜索</el-button>
          </el-form-item>
        </el-form>
        <div class="table">
          <el-table :data="ReturnTableData" style="width: 1720px" @selection-change="handleSelectionChange"
            max-height="650">
            <el-table-column type="selection" width="55" />
            <el-table-column label="sku图片" width="120">
              <template #default="scope">
                <el-image style="width: 40px; height: 40px" :src="scope.row.skuPicture" fit="fill" />
              </template>
            </el-table-column>
            <el-table-column label="店铺skuid" width="150">
              <template #default="scope">{{ scope.row.shopGoodSkuId }}</template>
            </el-table-column>
            <el-table-column label="sku信息" width="220">
              <template #default="scope">{{ scope.row.skuInfo }}</template>
            </el-table-column>
            <el-table-column label="采购单号" width="220">
              <template #default="scope">{{ scope.row.productPurchaseOrderCode }}</template>
            </el-table-column>
            <el-table-column label="采购时间" width="180">
              <template #default="scope">{{ scope.row.createTime }}</template>
            </el-table-column>
            <el-table-column label="入库时间" width="180">
              <template #default="scope">{{ scope.row.storageTime }}</template>
            </el-table-column>
            <el-table-column label="留仓时长" width="150">
              <template #default="scope">{{ scope.row.positionRetentionDays }}</template>
            </el-table-column>
            <el-table-column label="采购数量" width="150">
              <template #default="scope">{{ scope.row.purchaseNum }}</template>
            </el-table-column>
            <el-table-column label="采购单价" width="150">
              <template #default="scope">{{ scope.row.purchasePrice }}</template>
            </el-table-column>
            <el-table-column label="采购账号" width="150">
              <template #default="scope">{{ scope.row.purchaseCustomerName }}</template>
            </el-table-column>
            <el-table-column label="货主" width="150">
              <template #default="scope">{{ scope.row.orderStatusNam }}</template>
            </el-table-column>
            <el-table-column label="仓库" width="150">
              <template #default="scope">{{ scope.row.warehouseName }}</template>
            </el-table-column>
            <el-table-column label="库存数量" width="150">
              <template #default="scope">{{ scope.row.stockNum }}</template>
            </el-table-column>
            <el-table-column label="操作" width="150">
              <template #default="scope">
                <el-button link type="primary" size="small" @click.prevent="createReturnSucc(scope.row)">
                  生成退货信息
                </el-button>
              </template>
            </el-table-column>
          </el-table>
        </div>
        <div>
          <el-dialog v-model="createReturnNumdialogVisible" width="500">
            <span>
              退货数量：<el-input v-model="createReturnNumsForm.returnedNum" />
            </span>
            <template #footer>
              <div class="dialog-footer">
                <el-button @click="createReturnNumdialogVisible = false">取消</el-button>
                <el-button type="primary" @click="createReturnNumdialogVisibleSubmit">
                  确定
                </el-button>
              </div>
            </template>
          </el-dialog>
        </div>
      </el-tab-pane>
      <el-tab-pane label="全部" name="every">
        <el-form :model="everyListContentForm" inline>
          <el-form-item label="所属仓库：" style="width: 200px">
            <el-select v-model="everyListContentForm.warehouseId">
              <el-option label="全部" value="0" />
              <el-option :label="item.value" :value="item.key" v-for="item in returnWarehouse" :key="item.key" />
            </el-select>
          </el-form-item>
          <el-form-item label="采购订单号：">
            <el-input v-model="everyListContentForm.productPurchaseOrderCode" />
          </el-form-item>
          <el-form-item label="上家订单状态：">
            <el-select v-model="everyListContentForm.productPurchaseReturnedOrderStatusId">
              <el-option :label="item.orderStatusName" :value="item.id" v-for="item in store.topTypesForm"
                :key="item.id" />
            </el-select>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="everyListContent">搜索</el-button>
          </el-form-item>
        </el-form>
        <div class="table">
          <el-table :data="tableData" style="width: 1720px" @selection-change="handleSelectionChange" max-height="650">
            <el-table-column type="selection" width="55" />
            <el-table-column label="所属仓库" width="120">
              <template #default="scope">
                {{ scope.row.warehouseName }}
              </template>
            </el-table-column>
            <el-table-column label="入库批次" width="150">
              <template #default="scope">{{ scope.row.inboundBatchesCode }}</template>
            </el-table-column>
            <el-table-column label="sku信息" width="220">
              <template #default="scope">{{ scope.row.skuInfo }}</template>
            </el-table-column>
            <el-table-column label="接收时间" width="180">
              <template #default="scope">{{ scope.row.createTime }}</template>
            </el-table-column>
            <el-table-column label="采购订单号" width="220">
              <template #default="scope">{{ scope.row.productPurchaseOrderCode }}</template>
            </el-table-column>
            <el-table-column label="采购账号" width="150">
              <template #default="scope">{{ scope.row.purchaseCustomerName }}</template>
            </el-table-column>
            <el-table-column label="退货数量" width="150">
              <template #default="scope">{{ scope.row.purchaseNum }}</template>
            </el-table-column>
            <el-table-column label="上家状态" width="150">
              <template #default="scope">{{ scope.row.orderStatusName ? scope.row.orderStatusName :
                scope.row.processOrderStatus == 0 ? '待申请结果' : scope.row.processOrderStatus == 1 ? '上家同意退回' :
                  scope.row.processOrderStatus == 2 ? '上家拒绝退回' :
                    scope.row.processOrderStatus == 3 ? '上家拒收' : scope.row.processOrderStatus == 3 ? '退货成功' : ''
                }}</template>
            </el-table-column>
            <el-table-column label="出库状态" width="150">
              <template #default="scope">{{ scope.row.returnedOutStatus == 0 ? "未出库" : scope.row.returnedOutStatus
                == 1 ? "已出库" : '' }}</template>
            </el-table-column>
            <el-table-column label="操作" width="150">
              <template #default="scope">
                <el-button link type="primary" size="small" :disabled="true"
                  @click.prevent="createReturnSucc(scope.row)">
                  详情
                </el-button>
              </template>
            </el-table-column>
          </el-table>
        </div>
      </el-tab-pane>
      <el-tab-pane label="待申请" name="first">
        <el-form :model="awaitGet" inline>
          <el-form-item label="仓库：">
            <el-select v-model="awaitGet.warehouseId">
              <el-option :label="item.value" :value="item.key"
                v-for="item in store.productPurchaseReturnedListWarehouseDicTable" :key="item.key" />
            </el-select>
          </el-form-item>
          <el-form-item label="采购订单号：">
            <el-input v-model="awaitGet.productPurchaseOrderCode" />
          </el-form-item>
          <el-form-item label="上家订单状态：">
            <el-select v-model="awaitGet.productPurchaseReturnedOrderStatusId">
              <el-option :label="item.orderStatusName" :value="item.id" v-for="item in store.topTypesForm"
                :key="item.id" />
            </el-select>
          </el-form-item>
          <el-form-item label="申请状态：">
            <el-select v-model="awaitGet.returnedApplyStatus">
              <el-option label="未申请退货" value="0" />
              <el-option label="已申请退货" value="1" />
            </el-select>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="awaitGetSearch">搜索</el-button>
            <el-button type="primary" @click="OneApplication
              ">选中一键申请</el-button>
          </el-form-item>
        </el-form>
        <div class="table">
          <el-table :data="tableData" style="width: 100%" @selection-change="handleSelectionChange">
            <el-table-column type="selection" width="55" />
            <el-table-column label="所属仓库" width="120">
              <template #default="scope">{{ scope.row.warehouseName }}</template>
            </el-table-column>
            <el-table-column label="入库批次" width="150">
              <template #default="scope">{{ scope.row.inboundBatchesCode }}</template>
            </el-table-column>
            <el-table-column label="商品信息" width="220">
              <template #default="scope">{{ scope.row.skuInfo }}</template>
            </el-table-column>
            <el-table-column label="接收时间" width="180">
              <template #default="scope">{{ scope.row.createTime }}</template>
            </el-table-column>
            <el-table-column label="采购订单号" width="220">
              <template #default="scope">{{ scope.row.productPurchaseOrderCode }}</template>
            </el-table-column>
            <el-table-column label="采购账号" width="150">
              <template #default="scope">{{ scope.row.purchaseCustomerName }}</template>
            </el-table-column>
            <el-table-column label="退货数量" width="150">
              <template #default="scope">{{ scope.row.purchaseNum }}</template>
            </el-table-column>
            <el-table-column label="上家状态" width="150">
              <template #default="scope">{{ scope.row.orderStatusName ? scope.row.orderStatusName :
                scope.row.processOrderStatus == 0 ? '待申请结果' : scope.row.processOrderStatus == 1 ? '上家同意退回' :
                  scope.row.processOrderStatus == 2 ? '上家拒绝退回' :
                    scope.row.processOrderStatus == 3 ? '上家拒收' : scope.row.processOrderStatus == 3 ? '退货成功' : ''
                }}</template>
            </el-table-column>
            <el-table-column label="操作">
              <template #default="scope">
                <el-button link type="primary" size="small" @click.prevent="aReturnRequest(scope.row)">
                  向上家申请退货
                </el-button>
              </template>
            </el-table-column>
          </el-table>
        </div>
      </el-tab-pane>
      <!-- 已申请，待上家同意 -->
      <el-tab-pane label="已申请，待上家同意" name="ournew">
        <el-form :model="topConsentForm" inline>
          <el-form-item label="仓库：">
            <el-select v-model="topConsentForm.warehouseId">
              <el-option :label="item.value" :value="item.key"
                v-for="item in store.productPurchaseReturnedListWarehouseDicTable" :key="item.key" />
            </el-select>
          </el-form-item>
          <el-form-item label="采购订单号：">
            <el-input v-model="topConsentForm.productPurchaseOrderCode" />
          </el-form-item>
          <el-form-item label="上家订单状态：">
            <el-select v-model="topConsentForm.productPurchaseReturnedOrderStatusId">
              <el-option :label="item.orderStatusName" :value="item.id" v-for="item in store.topTypesForm"
                :key="item.id" />
            </el-select>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="topConsent">搜索</el-button>
            <!-- <el-button type="primary" @click="onSubmit">选中一键申请</el-button> -->
          </el-form-item>
        </el-form>
        <div class="table">
          <el-table :data="tableData" style="width: 100%" @selection-change="handleSelectionChange">
            <el-table-column type="selection" width="55" />
            <el-table-column label="所属仓库" width="120">
              <template #default="scope">{{ scope.row.warehouseName }}</template>
            </el-table-column>
            <el-table-column label="入库批次" width="150">
              <template #default="scope">{{ scope.row.inboundBatchesCode }}</template>
            </el-table-column>
            <el-table-column label="商品信息" width="220">
              <template #default="scope">{{ scope.row.skuInfo }}</template>
            </el-table-column>
            <el-table-column label="接收时间" width="180">
              <template #default="scope">{{ scope.row.createTime }}</template>
            </el-table-column>
            <el-table-column label="采购订单号" width="220">
              <template #default="scope">{{ scope.row.productPurchaseOrderCode }}</template>
            </el-table-column>
            <el-table-column label="采购账号" width="150">
              <template #default="scope">{{ scope.row.purchaseCustomerName }}</template>
            </el-table-column>
            <el-table-column label="退货数量" width="150">
              <template #default="scope">{{ scope.row.purchaseNum }}</template>
            </el-table-column>
            <el-table-column label="上家状态" width="150">
              <template #default="scope">{{ scope.row.orderStatusName ? scope.row.orderStatusName :
                scope.row.processOrderStatus == 0 ? '待申请结果' : scope.row.processOrderStatus == 1 ? '上家同意退回' :
                  scope.row.processOrderStatus == 2 ? '上家拒绝退回' :
                    scope.row.processOrderStatus == 3 ? '上家拒收' : scope.row.processOrderStatus == 3 ? '退货成功' : ''
                }}</template>
            </el-table-column>
            <el-table-column label="操作">
              <template #default="scope">
                <el-button link type="primary" size="small" disabled='true'
                  @click.prevent="lookOrderContent(scope.row)">
                  详情
                </el-button>
              </template>
            </el-table-column>
          </el-table>
        </div>
      </el-tab-pane>
      <el-tab-pane label="上家同意，待取号" name="PendingNumber">
        <el-form :model="awaitTakenumberForm" inline>
          <el-form-item label="所属仓库：" style="width: 200px">
            <el-select v-model="awaitTakenumberForm.warehouseId">
              <el-option label="全部" value="0" />
              <el-option :label="item.value" :value="item.key" v-for="item in returnWarehouse" :key="item.key" />
            </el-select>
          </el-form-item>
          <el-form-item label="采购订单号：">
            <el-input v-model="awaitTakenumberForm.productPurchaseOrderCode" />
          </el-form-item>
          <el-form-item label="上家订单状态：">
            <el-select v-model="awaitTakenumberForm.productPurchaseReturnedOrderStatusId">
              <el-option :label="item.orderStatusName" :value="item.id" v-for="item in store.topTypesForm"
                :key="item.id" />
            </el-select>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="awaitTakenumber">搜索</el-button>
          </el-form-item>
        </el-form>
        <div class="table">
          <el-table :data="tableData" style="width: 1720px" @selection-change="handleSelectionChange" max-height="650">
            <el-table-column type="selection" width="55" />
            <el-table-column label="所属仓库" width="120">
              <template #default="scope">
                {{ scope.row.warehouseName }}
              </template>
            </el-table-column>
            <el-table-column label="入库批次" width="150">
              <template #default="scope">{{ scope.row.inboundBatchesCode }}</template>
            </el-table-column>
            <el-table-column label="sku信息" width="220">
              <template #default="scope">{{ scope.row.skuInfo }}</template>
            </el-table-column>
            <el-table-column label="接收时间" width="180">
              <template #default="scope">{{ scope.row.createTime }}</template>
            </el-table-column>
            <el-table-column label="采购订单号" width="220">
              <template #default="scope">{{ scope.row.productPurchaseOrderCode }}</template>
            </el-table-column>
            <el-table-column label="采购账号" width="150">
              <template #default="scope">{{ scope.row.purchaseCustomerName }}</template>
            </el-table-column>
            <el-table-column label="退货数量" width="150">
              <template #default="scope">{{ scope.row.purchaseNum }}</template>
            </el-table-column>
            <el-table-column label="上家状态" width="150">
              <template #default="scope">{{ scope.row.orderStatusName ? scope.row.orderStatusName :
                scope.row.processOrderStatus == 0 ? '待申请结果' : scope.row.processOrderStatus == 1 ? '上家同意退回' :
                  scope.row.processOrderStatus == 2 ? '上家拒绝退回' :
                    scope.row.processOrderStatus == 3 ? '上家拒收' : scope.row.processOrderStatus == 3 ? '退货成功' : ''
                }}</template>
            </el-table-column>
            <el-table-column label="操作" width="200">
              <template #default="scope">
                <el-button link type="primary" size="small" :disabled="true"
                  @click.prevent="createReturnSucc(scope.row)">
                  详情
                </el-button>
                <el-button link type="primary" size="small" @click.prevent="aReturnRequest(scope.row)">
                  获取退回运单号
                </el-button>
              </template>
            </el-table-column>
          </el-table>
        </div>
      </el-tab-pane>
      <el-tab-pane label="待拣货" name="second">
        <el-form :model="topConsentFormGet" inline>
          <el-form-item label="仓库：">
            <el-select v-model="topConsentFormGet.warehouseId" style="width: 180px">
              <el-option :label="item.value" :value="item.key"
                v-for="item in store.productPurchaseReturnedListWarehouseDicTable" :key="item.key"
                @click='getKwNow(item.warehouseAreaDicList)' />
            </el-select>
          </el-form-item>
          <el-form-item label="货区：">
            <el-select v-model="topConsentFormGet.warehouseAreaIds" style="width: 180px">
              <el-option :label="item.value" :value="item.key" v-for="item in nowKw" :key='item.key' />
            </el-select>
          </el-form-item>
          <el-form-item label="采购订单号：">
            <el-input v-model="topConsentFormGet.productPurchaseOrderCode" style="width: 180px" />
          </el-form-item>
          <el-form-item label="上家订单状态：">
            <el-select v-model="topConsentFormGet.productPurchaseReturnedOrderStatusId" style="width: 180px">
              <el-option :label="item.orderStatusName" :value="item.id" v-for="item in store.topTypesForm"
                :key="item.id" />
            </el-select>
          </el-form-item>
          <!-- <el-form-item label="拣货状态：">
            <el-select v-model="topConsentFormGet.returnedPickStatus" style="width: 180px">
              <el-option label="待捡货 " :value="0" />
              <el-option label="捡货中" :value="1" />
              <el-option label="捡货完成" :value="2" />
            </el-select>
          </el-form-item> -->
          <el-form-item>
            <el-button type="primary" @click="topConsentAwait">搜索</el-button>
            <el-button type="primary" @click="getPrePickOrderDetailBtn(multipleSelection)">批量打印标签</el-button>
          </el-form-item>
        </el-form>
        <div class="table">
          <el-table :data="tableData" style="width: 100%" @selection-change="handleSelectionChange">
            <el-table-column type="selection" width="55" />
            <el-table-column label="所属仓库" width="120">
              <template #default="scope">{{ scope.row.warehouseName }}</template>
            </el-table-column>
            <el-table-column label="入库批次" width="150">
              <template #default="scope">{{ scope.row.inboundBatchesCode }}</template>
            </el-table-column>
            <el-table-column label="商品信息" width="220">
              <template #default="scope">{{ scope.row.skuInfo }}</template>
            </el-table-column>
            <el-table-column label="接收时间" width="180">
              <template #default="scope">{{ scope.row.createTime }}</template>
            </el-table-column>
            <el-table-column label="货位" width="220">
              <template #default="scope">{{ scope.row.warehouseAreaNames }}</template>
            </el-table-column>
            <el-table-column label="拣货数量" width="150">
              <template #default="scope">{{ scope.row.purchaseCustomerName }}</template>
            </el-table-column>
            <el-table-column label="拣货状态" width="150">
              <template #default="scope">{{ scope.row.returnedPickStatus == 0 ? '待拣货' :
                scope.row.returnedPickStatus == 1 ? '拣货中' : scope.row.returnedPickStatus == 2 ? '拣货完成' : ''
                }}</template>
            </el-table-column>
            <el-table-column label="上家状态" width="150">
              <template #default="scope">{{ scope.row.orderStatusName ? scope.row.orderStatusName :
                scope.row.processOrderStatus == 0 ? '待申请结果' : scope.row.processOrderStatus == 1 ? '上家同意退回' :
                  scope.row.processOrderStatus == 2 ? '上家拒绝退回' :
                    scope.row.processOrderStatus == 3 ? '上家拒收' : scope.row.processOrderStatus == 3 ? '退货成功' : ''
                }}</template>
            </el-table-column>
            <el-table-column label="操作">
              <template #default="scope">
                <el-button link type="primary" size="small" :disabled='true'
                  @click.prevent="lookOrderContent(scope.row)">
                  详情
                </el-button>
                <!-- <el-button link type="primary" size="small" @click.prevent="getPrePickOrderDetailBtn(scope.row.id)"
                  v-if='scope.row.returnedPickStatus == 1'>
                  重打拣货单
                </el-button> -->
                <el-button link type="primary" size="small" @click.prevent="getPrePickOrderDetailBtn(scope.row)">
                  打印标签
                </el-button>
                <!-- <el-button link type="primary" size="small" @click.prevent="aReturnRequest(scope.row)"
                  v-if='scope.row.returnedPickStatus == 2'>
                  获取退回运单号
                </el-button> -->

              </template>
            </el-table-column>
          </el-table>
        </div>
      </el-tab-pane>
      <!-- <el-tab-pane label="已拣货，待打包" name="third">
        <el-form :model="PickedAwaitPackForm" inline>
          <el-form-item label="仓库：">
            <el-select v-model="PickedAwaitPackForm.warehouseId">
              <el-option :label="item.value" :value="item.key"
                v-for="item in store.productPurchaseReturnedListWarehouseDicTable" :key="item.key"
                @click='getKwNow(item.warehouseAreaDicList)' />
            </el-select>
          </el-form-item>
          <el-form-item label="货区：">
            <el-select v-model="PickedAwaitPackForm.warehouseAreaIds">
              <el-option :label="item.value" :value="item.key" v-for="item in nowKw" :key='item.key' />
            </el-select>
          </el-form-item>
          <el-form-item label="采购订单号：">
            <el-input v-model="PickedAwaitPackForm.productPurchaseOrderCode" />
          </el-form-item>
          <el-form-item label="上家订单状态：">
            <el-select v-model="PickedAwaitPackForm.productPurchaseReturnedOrderStatusId">
              <el-option :label="item.orderStatusName" :value="item.id" v-for="item in store.topTypesForm"
                :key="item.id" />
            </el-select>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="PickedAwaitPack">搜索</el-button>
            <el-button type="primary" @click="batchPackingComplete">选中一键处理</el-button>
          </el-form-item>
        </el-form>
        <div class="table">
          <el-table :data="tableData" style="width: 100%" @selection-change="handleSelectionChange">
            <el-table-column type="selection" width="55" />
            <el-table-column label="所属仓库" width="120">
              <template #default="scope">{{ scope.row.warehouseName }}</template>
            </el-table-column>
            <el-table-column label="入库批次" width="150">
              <template #default="scope">{{ scope.row.inboundBatchesCode }}</template>
            </el-table-column>
            <el-table-column label="商品信息" width="220">
              <template #default="scope">{{ scope.row.skuInfo }}</template>
            </el-table-column>
            <el-table-column label="接收时间" width="180">
              <template #default="scope">{{ scope.row.createTime }}</template>
            </el-table-column>
            <el-table-column label="货位" width="220">
              <template #default="scope">{{ scope.row.warehouseAreaNames }}</template>
            </el-table-column>
            <el-table-column label="拣货数量" width="150">
              <template #default="scope">{{ scope.row.purchaseCustomerName }}</template>
            </el-table-column>
            <el-table-column label="拣货人" width="150">
              <template #default="scope">{{ scope.row.purchaseNum }}</template>
            </el-table-column>
            <el-table-column label="上家状态" width="150">
              <template #default="scope">{{ scope.row.orderStatusName ? scope.row.orderStatusName :
                scope.row.processOrderStatus == 0 ? '待申请结果' : scope.row.processOrderStatus == 1 ? '上家同意退回' :
                  scope.row.processOrderStatus == 2 ? '上家拒绝退回' :
                    scope.row.processOrderStatus == 3 ? '上家拒收' : scope.row.processOrderStatus == 3 ? '退货成功' : ''
                }}</template>
            </el-table-column>
            <el-table-column label="操作">
              <template #default="scope">
                <el-button link type="primary" size="small" :disabled='true'
                  @click.prevent="lookOrderContent(scope.row)">
                  详情
                </el-button>
                <el-button link type="primary" size="small" @click.prevent="PackingComplete(scope.row)">
                  打包完成
                </el-button>
              </template>
            </el-table-column>
          </el-table>
        </div>
      </el-tab-pane> -->
      <el-tab-pane label="待出库" name="awaitOut">
        <el-form :model="PackAwaitOutForm" inline>
          <el-form-item label="仓库：">
            <el-select v-model="PackAwaitOutForm.warehouseId">
              <el-option :label="item.value" :value="item.key"
                v-for="item in store.productPurchaseReturnedListWarehouseDicTable" :key="item.key"
                @click='getKwNow(item.warehouseAreaDicList)' />
            </el-select>
          </el-form-item>
          <el-form-item label="货区：">
            <el-select v-model="PackAwaitOutForm.warehouseAreaIds">
              <el-option :label="item.value" :value="item.key" v-for="item in nowKw" :key='item.key' />
            </el-select>
          </el-form-item>
          <el-form-item label="采购订单号：">
            <el-input v-model="PackAwaitOutForm.productPurchaseOrderCode" />
          </el-form-item>
          <el-form-item label="上家订单状态：">
            <el-select v-model="PackAwaitOutForm.productPurchaseReturnedOrderStatusId">
              <el-option :label="item.orderStatusName" :value="item.id" v-for="item in store.topTypesForm"
                :key="item.id" />
            </el-select>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="PackAwaitOut">搜索</el-button>
            <!-- <el-button type="primary" @click="batchOutHouse">选中一键处理</el-button> -->
          </el-form-item>
        </el-form>
        <div class="table">
          <el-table :data="tableData" style="width: 1720px" @selection-change="handleSelectionChange">
            <el-table-column type="selection" width="55" />
            <el-table-column label="所属仓库" width="120">
              <template #default="scope">{{ scope.row.warehouseName }}</template>
            </el-table-column>
            <el-table-column label="入库批次" width="150">
              <template #default="scope">{{ scope.row.inboundBatchesCode }}</template>
            </el-table-column>
            <el-table-column label="商品信息" width="220">
              <template #default="scope">{{ scope.row.skuInfo }}</template>
            </el-table-column>
            <el-table-column label="拣货数量" width="150">
              <template #default="scope">{{ scope.row.purchaseCustomerName }}</template>
            </el-table-column>
            <el-table-column label="拣货人" width="150">
              <template #default="scope">{{ scope.row.purchaseNum }}</template>
            </el-table-column>
            <el-table-column label="拣货时间" width="180">
              <template #default="scope">{{ scope.row.createTime }}</template>
            </el-table-column>
            <el-table-column label="打包人" width="220">
              <template #default="scope">{{ scope.row.productPurchaseOrderCode }}</template>
            </el-table-column>
            <el-table-column label="打包时间" width="180">
              <template #default="scope">{{ scope.row.createTime }}</template>
            </el-table-column>
            <el-table-column label="上家状态" width="150">
              <template #default="scope">{{ scope.row.orderStatusName ? scope.row.orderStatusName :
                scope.row.processOrderStatus == 0 ? '待申请结果' : scope.row.processOrderStatus == 1 ? '上家同意退回' :
                  scope.row.processOrderStatus == 2 ? '上家拒绝退回' :
                    scope.row.processOrderStatus == 3 ? '上家拒收' : scope.row.processOrderStatus == 3 ? '退货成功' : ''
                }}</template>
            </el-table-column>
            <el-table-column label="操作" width="180">
              <template #default="scope">
                <el-button link type="primary" size="small" :disabled='true'
                  @click.prevent="lookOrderContent(scope.row)">
                  详情
                </el-button>
                <!-- <el-button link type="primary" size="small" @click.prevent="outHouse(scope.row)">
                  出库
                </el-button> -->
                <el-button link type="primary" size="small" @click.prevent="getPrePickOrderDetailBtn(scope.row)">
                  重打标签
                </el-button>
              </template>
            </el-table-column>
          </el-table>
        </div>
      </el-tab-pane>
      <el-tab-pane label="已出库" name="OutOfStorage">
        <el-form :model="deliveryForm" inline>
          <el-form-item label="仓库：">
            <el-select v-model="deliveryForm.warehouseId">
              <el-option :label="item.value" :value="item.key"
                v-for="item in store.productPurchaseReturnedListWarehouseDicTable" :key="item.key"
                @click='getKwNow(item.warehouseAreaDicList)' />
            </el-select>
          </el-form-item>
          <el-form-item label="货区：">
            <el-select v-model="deliveryForm.warehouseAreaIds">
              <el-option :label="item.value" :value="item.key" v-for="item in nowKw" :key='item.key' />
            </el-select>
          </el-form-item>
          <el-form-item label="采购订单号：">
            <el-input v-model="deliveryForm.productPurchaseOrderCode" />
          </el-form-item>
          <el-form-item label="上家订单状态：">
            <el-select v-model="deliveryForm.productPurchaseReturnedOrderStatusId">
              <el-option :label="item.orderStatusName" :value="item.id" v-for="item in store.topTypesForm"
                :key="item.id" />
            </el-select>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="delivery">搜索</el-button>
            <!-- <el-button type="primary" @click="onSubmit">选中一键申请</el-button> -->
          </el-form-item>
        </el-form>
        <div class="table">
          <el-table :data="tableData" style="width: 100%" @selection-change="handleSelectionChange">
            <el-table-column type="selection" width="55" />
            <el-table-column label="所属仓库" width="120">
              <template #default="scope">{{ scope.row.warehouseName }}</template>
            </el-table-column>
            <el-table-column label="入库批次" width="150">
              <template #default="scope">{{ scope.row.inboundBatchesCode }}</template>
            </el-table-column>
            <el-table-column label="商品信息" width="220">
              <template #default="scope">{{ scope.row.skuInfo }}</template>
            </el-table-column>
            <el-table-column label="拣货数量" width="150">
              <template #default="scope">{{ scope.row.purchaseCustomerName }}</template>
            </el-table-column>
            <el-table-column label="拣货人" width="150">
              <template #default="scope">{{ scope.row.purchaseNum }}</template>
            </el-table-column>
            <el-table-column label="拣货时间" width="180">
              <template #default="scope">{{ scope.row.createTime }}</template>
            </el-table-column>
            <el-table-column label="打包人" width="220">
              <template #default="scope">{{ scope.row.productPurchaseOrderCode }}</template>
            </el-table-column>
            <el-table-column label="打包时间" width="180">
              <template #default="scope">{{ scope.row.createTime }}</template>
            </el-table-column>
            <el-table-column label="上家状态" width="150">
              <template #default="scope">{{ scope.row.orderStatusName ? scope.row.orderStatusName :
                scope.row.processOrderStatus == 0 ? '待申请结果' : scope.row.processOrderStatus == 1 ? '上家同意退回' :
                  scope.row.processOrderStatus == 2 ? '上家拒绝退回' :
                    scope.row.processOrderStatus == 3 ? '上家拒收' : scope.row.processOrderStatus == 3 ? '退货成功' : ''
                }}</template>
            </el-table-column>
            <el-table-column label="操作">
              <template #default="scope">
                <el-button link type="primary" size="small" :disabled='true'
                  @click.prevent="lookOrderContent(scope.row)">
                  详情
                </el-button>
              </template>
            </el-table-column>
          </el-table>
        </div>
      </el-tab-pane>
      <el-tab-pane label="申请退货被上家拒绝" name="returnOrder">
        <el-form :model="returnRequestBeRejectedForm" inline>
          <el-form-item label="仓库：">
            <el-select v-model="returnRequestBeRejectedForm.warehouseId">
              <el-option :label="item.value" :value="item.key"
                v-for="item in store.productPurchaseReturnedListWarehouseDicTable" :key="item.key"
                @click='getKwNow(item.warehouseAreaDicList)' />
            </el-select>
          </el-form-item>
          <el-form-item label="货区：">
            <el-select v-model="returnRequestBeRejectedForm.warehouseAreaIds">
              <el-option :label="item.value" :value="item.key" v-for="item in nowKw" :key='item.key' />
            </el-select>
          </el-form-item>
          <el-form-item label="采购订单号：">
            <el-input v-model="returnRequestBeRejectedForm.productPurchaseOrderCode" />
          </el-form-item>
          <el-form-item label="上家订单状态：">
            <el-select v-model="returnRequestBeRejectedForm.productPurchaseReturnedOrderStatusId">
              <el-option :label="item.orderStatusName" :value="item.id" v-for="item in store.topTypesForm"
                :key="item.id" />
            </el-select>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="returnRequestBeRejected">搜索</el-button>
            <el-button type="primary" @click="OneApplication">选中一键申请</el-button>
          </el-form-item>
        </el-form>
        <div class="table">
          <el-table :data="tableData" style="width: 100%" @selection-change="handleSelectionChange">
            <el-table-column type="selection" width="55" />
            <el-table-column label="所属仓库" width="120">
              <template #default="scope">{{ scope.row.warehouseName }}</template>
            </el-table-column>
            <el-table-column label="入库批次" width="150">
              <template #default="scope">{{ scope.row.inboundBatchesCode }}</template>
            </el-table-column>
            <el-table-column label="商品信息" width="220">
              <template #default="scope">{{ scope.row.skuInfo }}</template>
            </el-table-column>
            <el-table-column label="采购订单号" width="150">
              <template #default="scope">{{ scope.row.productPurchaseOrderCode }}</template>
            </el-table-column>
            <el-table-column label="采购账号" width="180">
              <template #default="scope">{{ scope.row.purchaseCustomerName }}</template>
            </el-table-column>
            <el-table-column label="退货数量" width="220">
              <template #default="scope">{{ scope.row.returnedPickNum }}</template>
            </el-table-column>
            <el-table-column label="申请退货时间" width="180">
              <template #default="scope">{{ scope.row.createTime }}</template>
            </el-table-column>
            <el-table-column label="上家状态" width="150">
              <template #default="scope">{{ scope.row.orderStatusName ? scope.row.orderStatusName :
                scope.row.processOrderStatus == 0 ? '待申请结果' : scope.row.processOrderStatus == 1 ? '上家同意退回' :
                  scope.row.processOrderStatus == 2 ? '上家拒绝退回' :
                    scope.row.processOrderStatus == 3 ? '上家拒收' : scope.row.processOrderStatus == 3 ? '退货成功' : ''
                }}</template>
            </el-table-column>
            <el-table-column label="操作">
              <template #default="scope">
                <el-button link type="primary" size="small" :disabled='true'
                  @click.prevent="lookOrderContent(scope.row)">
                  详情
                </el-button>
                <el-button link type="primary" size="small" v-if='scope.row.returnedPickStatus == 2'
                  @click.prevent="aReturnRequest(scope.row)">
                  申请退货
                </el-button>
              </template>
            </el-table-column>
          </el-table>
        </div>
      </el-tab-pane>
      <el-tab-pane label="发货后上家拒收" name="fourth">
        <el-tabs v-model="fourthactiveName" type="card" class="demo-tabs" @tab-click='changefourthactiveName'>
          <el-tab-pane label="一次处理" name="fourthfirst">
            <el-form :model="deliverGoodsBeRejectedForm" inline>
              <el-form-item label="所属仓库：">
                <el-select v-model="deliverGoodsBeRejectedForm.warehouseId">
                  <el-option :label="item.value" :value="item.key"
                    v-for="item in store.productPurchaseReturnedListWarehouseDicTable" :key="item.key"
                    @click='getKwNow(item.warehouseAreaDicList)' />
                </el-select>
              </el-form-item>
              <el-form-item label="采购订单号：">
                <el-input v-model="deliverGoodsBeRejectedForm.productPurchaseOrderCode" />
              </el-form-item>
              <el-form-item>
                <el-button type="primary" @click="changefourthactiveName">搜索</el-button>
              </el-form-item>
            </el-form>
            <div class="table">
              <el-table :data="tableData" style="max-width: 1630px;" election-change="handleSelectionChange">
                <el-table-column type="selection" width="55" />
                <el-table-column label="所属仓库" width="120">
                  <template #default="scope">{{ scope.row.warehouseName }}</template>
                </el-table-column>
                <el-table-column label="入库批次" width="150">
                  <template #default="scope">{{ scope.row.inboundBatchesCode }}</template>
                </el-table-column>
                <el-table-column label="商品信息" width="220">
                  <template #default="scope">{{ scope.row.skuInfo }}</template>
                </el-table-column>
                <el-table-column label="采购订单号" width="150">
                  <template #default="scope">{{ scope.row.productPurchaseOrderCode }}</template>
                </el-table-column>
                <el-table-column label="采购账号" width="180">
                  <template #default="scope">{{ scope.row.purchaseCustomerName }}</template>
                </el-table-column>
                <el-table-column label="退货数量" width="220">
                  <template #default="scope">{{ scope.row.returnedPickNum }}</template>
                </el-table-column>
                <el-table-column label="申请退货时间" width="180">
                  <template #default="scope">{{ scope.row.createTime }}</template>
                </el-table-column>
                <el-table-column label="上家状态" width="150">
                  <template #default="scope">{{ scope.row.orderStatusName ? scope.row.orderStatusName :
                    scope.row.processOrderStatus == 0 ? '待申请结果' : scope.row.processOrderStatus == 1 ? '上家同意退回' :
                      scope.row.processOrderStatus == 2 ? '上家拒绝退回' :
                        scope.row.processOrderStatus == 3 ? '上家拒收' : scope.row.processOrderStatus == 3 ? '退货成功' : ''
                    }}</template>
                </el-table-column>
                <el-table-column label="打标类型" width="180">
                  <template #default="scope">{{ scope.row.handleStatus }}</template>
                </el-table-column>
                <el-table-column label="操作" width="180">
                  <template #default="scope">
                    <el-button link type="primary" size="small" disabled='true'
                      @click.prevent="lookOrderContent(scope.row)">
                      详情
                    </el-button>
                    <el-button link type="primary" size="small" @click.prevent="markingOne(scope.row)">
                      打标记
                    </el-button>
                  </template>
                </el-table-column>
              </el-table>
            </div>
          </el-tab-pane>
          <el-tab-pane label="二次处理" name="fourthsecond">
            <el-form :model="deliverGoodsBeRejectedForm" inline>
              <el-form-item label="所属仓库：">
                <el-select v-model="deliverGoodsBeRejectedForm.warehouseId">
                  <el-option :label="item.value" :value="item.key"
                    v-for="item in store.productPurchaseReturnedListWarehouseDicTable" :key="item.key"
                    @click='getKwNow(item.warehouseAreaDicList)' />
                </el-select>
              </el-form-item>
              <el-form-item label="采购订单号：">
                <el-input v-model="deliverGoodsBeRejectedForm.productPurchaseOrderCode" />
              </el-form-item>
              <el-form-item>
                <el-button type="primary" @click="changefourthactiveName">搜索</el-button>
              </el-form-item>
            </el-form>
            <div class="table">
              <el-table :data="tableData" style="max-width: 1630px;" @selection-change="handleSelectionChange">
                <el-table-column type="selection" width="55" />
                <el-table-column label="所属仓库" width="120">
                  <template #default="scope">{{ scope.row.warehouseName }}</template>
                </el-table-column>
                <el-table-column label="入库批次" width="150">
                  <template #default="scope">{{ scope.row.inboundBatchesCode }}</template>
                </el-table-column>
                <el-table-column label="商品信息" width="220">
                  <template #default="scope">{{ scope.row.skuInfo }}</template>
                </el-table-column>
                <el-table-column label="采购订单号" width="150">
                  <template #default="scope">{{ scope.row.productPurchaseOrderCode }}</template>
                </el-table-column>
                <el-table-column label="采购账号" width="180">
                  <template #default="scope">{{ scope.row.purchaseCustomerName }}</template>
                </el-table-column>
                <el-table-column label="退货数量" width="220">
                  <template #default="scope">{{ scope.row.returnedPickNum }}</template>
                </el-table-column>
                <el-table-column label="申请退货时间" width="180">
                  <template #default="scope">{{ scope.row.createTime }}</template>
                </el-table-column>
                <el-table-column label="上家状态" width="150">
                  <template #default="scope">{{ scope.row.orderStatusName ? scope.row.orderStatusName :
                    scope.row.processOrderStatus == 0 ? '待申请结果' : scope.row.processOrderStatus == 1 ? '上家同意退回' :
                      scope.row.processOrderStatus == 2 ? '上家拒绝退回' :
                        scope.row.processOrderStatus == 3 ? '上家拒收' : scope.row.processOrderStatus == 3 ? '退货成功' : ''
                    }}</template>
                </el-table-column>
                <el-table-column label="打标类型" width="180">
                  <template #default="scope">{{ scope.row.handleStatus }}</template>
                </el-table-column>
                <el-table-column label="操作" width='220'>
                  <template #default="scope">
                    <el-button link type="primary" size="small" disabled='true'
                      @click.prevent="lookOrderContent(scope.row)">
                      详情
                    </el-button>
                    <el-button link type="primary" size="small" @click.prevent="markingOne(scope.row)">
                      打标记
                    </el-button>
                    <el-button link type="primary" size="small" @click.prevent="noMarking(scope.row)">
                      不可处理
                    </el-button>
                  </template>
                </el-table-column>
              </el-table>
            </div>
          </el-tab-pane>
          <el-tab-pane label="不可处理待审核" name="fourththird">
            <el-form :model="deliverGoodsBeRejectedForm" inline>
              <el-form-item label="所属仓库：">
                <el-select v-model="deliverGoodsBeRejectedForm.warehouseId">
                  <el-option :label="item.value" :value="item.key"
                    v-for="item in store.productPurchaseReturnedListWarehouseDicTable" :key="item.key"
                    @click='getKwNow(item.warehouseAreaDicList)' />
                </el-select>
              </el-form-item>
              <el-form-item label="采购订单号：">
                <el-input v-model="deliverGoodsBeRejectedForm.productPurchaseOrderCode" />
              </el-form-item>
              <el-form-item>
                <el-button type="primary" @click="changefourthactiveName">搜索</el-button>
              </el-form-item>
            </el-form>
            <div class="table">
              <el-table :data="tableData" style="max-width: 1630px;" @selection-change="handleSelectionChange">
                <el-table-column type="selection" width="55" />
                <el-table-column label="所属仓库" width="120">
                  <template #default="scope">{{ scope.row.warehouseName }}</template>
                </el-table-column>
                <el-table-column label="入库批次" width="150">
                  <template #default="scope">{{ scope.row.inboundBatchesCode }}</template>
                </el-table-column>
                <el-table-column label="商品信息" width="220">
                  <template #default="scope">{{ scope.row.skuInfo }}</template>
                </el-table-column>
                <el-table-column label="采购订单号" width="150">
                  <template #default="scope">{{ scope.row.productPurchaseOrderCode }}</template>
                </el-table-column>
                <el-table-column label="采购账号" width="180">
                  <template #default="scope">{{ scope.row.purchaseCustomerName }}</template>
                </el-table-column>
                <el-table-column label="退货数量" width="220">
                  <template #default="scope">{{ scope.row.returnedPickNum }}</template>
                </el-table-column>
                <el-table-column label="申请退货时间" width="180">
                  <template #default="scope">{{ scope.row.createTime }}</template>
                </el-table-column>
                <el-table-column label="上家状态" width="150">
                  <template #default="scope">{{ scope.row.orderStatusName ? scope.row.orderStatusName :
                    scope.row.processOrderStatus == 0 ? '待申请结果' : scope.row.processOrderStatus == 1 ? '上家同意退回' :
                      scope.row.processOrderStatus == 2 ? '上家拒绝退回' :
                        scope.row.processOrderStatus == 3 ? '上家拒收' : scope.row.processOrderStatus == 3 ? '退货成功' : ''
                    }}</template>
                </el-table-column>
                <el-table-column label="一次标记类型" width="180">
                  <template #default="scope">{{ scope.row.handleOneProcessStatus }}</template>
                </el-table-column>
                <el-table-column label="二次标记类型" width="180">
                  <template #default="scope">{{ scope.row.handleTowProcessStatus }}</template>
                </el-table-column>
                <el-table-column label="操作" width='180'>
                  <template #default="scope">
                    <el-button link type="primary" size="small" disabled='true'
                      @click.prevent="lookOrderContent(scope.row)">
                      详情
                    </el-button>
                    <el-button link type="primary" size="small"
                      @click.prevent="returnedHandleCannotVerifypassBtn(scope.row)">
                      同意
                    </el-button>
                    <el-button link type="primary" size="small"
                      @click.prevent="returnedHandleCannotVerifycancelBtn(scope.row)">
                      拒绝
                    </el-button>
                  </template>
                </el-table-column>
              </el-table>
            </div>
          </el-tab-pane>
          <el-tab-pane label="不可处理" name="fourthfourth">
            <el-form :model="deliverGoodsBeRejectedForm" inline>
              <el-form-item label="所属仓库：">
                <el-select v-model="deliverGoodsBeRejectedForm.warehouseId">
                  <el-option :label="item.value" :value="item.key"
                    v-for="item in store.productPurchaseReturnedListWarehouseDicTable" :key="item.key"
                    @click='getKwNow(item.warehouseAreaDicList)' />
                </el-select>
              </el-form-item>
              <el-form-item label="采购订单号：">
                <el-input v-model="deliverGoodsBeRejectedForm.productPurchaseOrderCode" />
              </el-form-item>
              <el-form-item>
                <el-button type="primary" @click="changefourthactiveName">搜索</el-button>
              </el-form-item>
            </el-form>
            <div class="table">
              <el-table :data="tableData" style="max-width: 1630px;" @selection-change="handleSelectionChange">
                <el-table-column type="selection" width="55" />
                <el-table-column label="所属仓库" width="120">
                  <template #default="scope">{{ scope.row.warehouseName }}</template>
                </el-table-column>
                <el-table-column label="入库批次" width="150">
                  <template #default="scope">{{ scope.row.inboundBatchesCode }}</template>
                </el-table-column>
                <el-table-column label="商品信息" width="220">
                  <template #default="scope">{{ scope.row.skuInfo }}</template>
                </el-table-column>
                <el-table-column label="采购订单号" width="150">
                  <template #default="scope">{{ scope.row.productPurchaseOrderCode }}</template>
                </el-table-column>
                <el-table-column label="采购账号" width="180">
                  <template #default="scope">{{ scope.row.purchaseCustomerName }}</template>
                </el-table-column>
                <el-table-column label="退货数量" width="220">
                  <template #default="scope">{{ scope.row.returnedPickNum }}</template>
                </el-table-column>
                <el-table-column label="申请退货时间" width="180">
                  <template #default="scope">{{ scope.row.createTime }}</template>
                </el-table-column>
                <el-table-column label="上家状态" width="150">
                  <template #default="scope">{{ scope.row.orderStatusName ? scope.row.orderStatusName :
                    scope.row.processOrderStatus == 0 ? '待申请结果' : scope.row.processOrderStatus == 1 ? '上家同意退回' :
                      scope.row.processOrderStatus == 2 ? '上家拒绝退回' :
                        scope.row.processOrderStatus == 3 ? '上家拒收' : scope.row.processOrderStatus == 3 ? '退货成功' : ''
                    }}</template>
                </el-table-column>
                <el-table-column label="一次标记类型" width="180">
                  <template #default="scope">{{ scope.row.handleOneProcessStatus }}</template>
                </el-table-column>
                <el-table-column label="二次标记类型" width="180">
                  <template #default="scope">{{ scope.row.handleTowProcessStatus }}</template>
                </el-table-column>
              </el-table>
            </div>
          </el-tab-pane>
        </el-tabs>
        <el-dialog v-model="markingdialogVisible" width="500">
          <span>
            打标类型<el-select v-model="TypeMarking">
              <el-option :label="item.value" :value="item.key" v-for="item in markingdialogVisibleType"
                :key="item.key" />
            </el-select>
          </span>
          <template #footer>
            <div class="dialog-footer">
              <el-button @click="markingdialogVisible = false">取消</el-button>
              <el-button type="primary" @click="submitmarking">
                确定
              </el-button>
            </div>
          </template>
        </el-dialog>
      </el-tab-pane>
      <el-tab-pane label="取号失败" name="retlowSer">
        <el-form :model="FailureSearchForm" inline>
          <el-form-item label="采购订单号：">
            <el-input v-model="FailureSearchForm.productPurchaseOrderCode" />
          </el-form-item>
          <el-form-item label="失败原因:">
            <el-select v-model="FailureSearchForm.failMsg">
              <el-option :label="item.value" :value="item.key" v-for="item in listReturnedWaybillCodeFailMsgDicForm"
                :key="item.key" />
            </el-select>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="FailureSearch">搜索</el-button>
            <el-button type="primary" @click="OneApplication">选中一键重新获取</el-button>
          </el-form-item>
        </el-form>
        <div class="table">
          <el-table :data="tableData" style="width: 1355px" border @selection-change="handleSelectionChange">
            <el-table-column type="selection" width="55" />
            <el-table-column label="采购订单号" width="220">
              <template #default="scope">{{ scope.row.productPurchaseOrderCode }}</template>
            </el-table-column>
            <el-table-column label="申请退货时间" width="220">
              <template #default="scope">{{ scope.row.createTime }}</template>
            </el-table-column>
            <el-table-column label="失败原因" width="550">
              <template #default="scope">{{ scope.row.productWaybillCodeFailMsg }}</template>
            </el-table-column>
            <el-table-column label="失败快递" width="150">
              <template #default="scope">{{ scope.row.orderLogisticsCompany }}</template>
            </el-table-column>
            <el-table-column label="操作" width="160">
              <template #default="scope">
                <el-button link type="primary" size="small" v-if='scope.row.productWaybillCodeFailMsg != "物流停发"'
                  @click.prevent="aReturnRequest(scope.row)">
                  重新获取
                </el-button>
                <el-button link type="primary" size="small" v-if='scope.row.productWaybillCodeFailMsg == "物流停发"'
                  @click.prevent="ExchangeExpress(scope.row)">
                  换快递
                </el-button>
              </template>
            </el-table-column>
          </el-table>
        </div>
        <el-dialog v-model="retlowSerDialogVisible" width="500">
          <span>
            选择快递<el-select v-model="expressNow">
              <el-option :label="item.name" :value="item.id" v-for="item in rowNowContent" :key="item.key" />
            </el-select>
          </span>
          <template #footer>
            <div class="dialog-footer">
              <el-button @click="retlowSerDialogVisible = false">取消</el-button>
              <el-button type="primary" @click="submitExpress">
                确定
              </el-button>
            </div>
          </template>
        </el-dialog>
      </el-tab-pane>

      <el-tab-pane label="无识别状态" name="notHead">
        <el-form :model="notfindOrderForm" inline>
          <el-form-item label="仓库：">
            <el-select v-model="notfindOrderForm.warehouseId">
              <el-option :label="item.value" :value="item.key"
                v-for="item in store.productPurchaseReturnedListWarehouseDicTable" :key="item.key" />
            </el-select>
          </el-form-item>
          <el-form-item label="货区：">
            <el-select v-model="notfindOrderForm.warehouseAreaId">
              <el-option :label="item.value" :value="item.key" v-for="item in nowKw" :key='item.key' />
            </el-select>
          </el-form-item>
          <el-form-item label="采购订单号：">
            <el-input v-model="notfindOrderForm.productPurchaseOrderCode" />
          </el-form-item>
          <el-form-item label="上家订单状态：">
            <el-select v-model="notfindOrderForm.productPurchaseReturnedOrderStatusId">
              <el-option :label="item.orderStatusName" :value="item.id" v-for="item in store.topTypesForm"
                :key="item.id" />
            </el-select>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="notfindOrderFormSearch">搜索</el-button>
            <!-- <el-button type="primary" @click="onSubmit">选中一键申请</el-button> -->
          </el-form-item>
        </el-form>
        <div class="table">
          <el-table :data="tableData" style="width: 100%" @selection-change="handleSelectionChange">
            <el-table-column type="selection" width="55" />
            <el-table-column label="所属仓库" width="120">
              <template #default="scope">{{ scope.row.warehouseName }}</template>
            </el-table-column>
            <el-table-column label="入库批次" width="220">
              <template #default="scope">{{ scope.row.inboundBatchesCode }}</template>
            </el-table-column>
            <el-table-column label="商品信息" width="220">
              <template #default="scope">{{ scope.row.skuInfo }}</template>
            </el-table-column>
            <el-table-column label="接收时间" width="220">
              <template #default="scope">{{ scope.row.createTime }}</template>
            </el-table-column>
            <el-table-column label="采购订单号" width="222">
              <template #default="scope">{{ scope.row.productPurchaseOrderCode }}</template>
            </el-table-column>
            <el-table-column label="采购账号" width="180">
              <template #default="scope">{{ scope.row.purchaseCustomerName }}</template>
            </el-table-column>
            <el-table-column label="退货数量" width="120">
              <template #default="scope">{{ scope.row.purchaseNum }}</template>
            </el-table-column>
            <el-table-column label="上家状态" width="222">
              <template #default="scope">{{ scope.row.orderStatusName ? scope.row.orderStatusName :
                scope.row.processOrderStatus == 0 ? '待申请结果' : scope.row.processOrderStatus == 1 ? '上家同意退回' :
                  scope.row.processOrderStatus == 2 ? '上家拒绝退回' :
                    scope.row.processOrderStatus == 3 ? '上家拒收' : scope.row.processOrderStatus == 3 ? '退货成功' : ''
                }}</template>
            </el-table-column>
            <el-table-column label="操作">
              <template #default="scope">
                <el-button link type="primary" size="small" disabled='true'
                  @click.prevent="lookOrderContent(scope.row)">
                  详情
                </el-button>
              </template>
            </el-table-column>
          </el-table>
        </div>
      </el-tab-pane>
    </el-tabs>

  </div>
  <div class="page">
    <el-pagination v-model:current-page="currentPage4" v-model:page-size="pageSize4" :page-sizes="[10, 50, 100]"
      layout="total, sizes, prev, pager, next, jumper" :total="total" @size-change="handleSizeChange"
      @current-change="handleCurrentChange" />
  </div>
</template>

<script setup>
import { ref, onBeforeMount, onBeforeUnmount, onMounted } from 'vue'
// productPurchaseReturnedpurchaseReturnedWaybillCode,productPurchaseReturnedOutPurchaseReturned
import { productPurchaseReturnedList, productPurchaseReturnedApplyPurchaseReturned, productPurchaseReturnedPrintPurchaseReturned, positionRetentionWarningList, createPurchaseCustomerDic, productPurchaseReturnedCreatePurchaseReturned, createPurchaseWarehouseDic, waybillcodelist, listReturnedWaybillCodeFailMsgDic, returnedHandleCannotVerifypass, productPurchaseReturnedWaybillcode, waybillcodechangeExpress, listReturnedMarkInfoDic, returnedMarkInfomake, returnedHandleCannot, returnedHandleCannotVerifycancel } from '@/api/index'
import { ElMessage } from 'element-plus'
import { useAlertsStore } from '@/store/index'
const activeName = ref('return110')
const store = useAlertsStore()
onBeforeMount(() => {
  createPurchaseWarehouseDicBtn()
  createPurchaseCustomerDicBtn()
  store.productPurchaseReturnedListWarehouseDicBtn()
  store.topTypes()
})
const handleClick = (tab, event) => {
  console.log(tab)
  nowKw.value = []
  if (tab) {
    activeName.value = tab.props ? tab.props.name : activeName.value
  }
  if (activeName.value === 'return110') {
    returnSearch()
  }
  if (activeName.value === 'PendingNumber') {
    awaitTakenumber()
  }
  if (activeName.value === 'every') {
    everyListContent()
  }
  if (activeName.value === 'first') {
    awaitGetSearch()
  }
  if (activeName.value === 'ournew') {
    topConsent()
  }
  if (activeName.value === 'second') {
    topConsentAwait()
  }
  if (activeName.value === 'third') {
    PickedAwaitPack()
  }
  if (activeName.value === 'awaitOut') {
    PackAwaitOut()
  }
  if (activeName.value === 'OutOfStorage') {
    delivery()
  }
  if (activeName.value === 'returnOrder') {
    returnRequestBeRejected()
  }
  if (activeName.value === 'fourth') {
    if (fourthactiveName.value === 'fourthfirst') {
      console.log('这个')
      deliverGoodsBeRejectedForm.value.handleStatus = 1
      deliverGoodsBeRejected()
    }
    if (fourthactiveName.value === 'fourthsecond') {
      deliverGoodsBeRejectedForm.value.handleStatus = 2
      deliverGoodsBeRejected()
    }
    if (fourthactiveName.value === 'fourththird') {
      deliverGoodsBeRejectedForm.value.handleStatus = 3
      deliverGoodsBeRejected()
    }
    if (fourthactiveName.value === 'fourthfourth') {
      deliverGoodsBeRejectedForm.value.handleStatus = 4
      deliverGoodsBeRejected()
    }
  }
  if (activeName.value === 'notHead') {
    notfindOrderFormSearch()
  }
  if (activeName.value === 'retlowSer') {
    listReturnedWaybillCodeFailMsgDicApi()
    FailureSearch()
  }
}
const pageForm = ref({
  pageSize: 10,
  pageNum: 1
})
// const form = ref({})
// table多选
const multipleSelection = ref([])
const handleSelectionChange = (val) => {
  multipleSelection.value = val
}
const getList = (val) => {
  productPurchaseReturnedList(val).then(res => {
    const { data: { data } } = res
    total.value = data.total
    tableData.value = data.list
    console.log('data')
    console.log(data)
  })
}
// tuihuo
const returnOrderForm = ref({
  purchaseTimeStart: '',
  purchaseTimeEnd: '',
  warehouseId: '0',
  purchaseCustomerName: '',
  productPurchaseOrderCode: '',
  shopGoodSkuId: ''
})
const ReturnTableData = ref([])
const returnSearch = () => {
  if (returnOrdertimes.value.length > 0) {
    returnOrderForm.value.purchaseTimeStart = returnOrdertimes.value[0]
    returnOrderForm.value.purchaseTimeEnd = returnOrdertimes.value[1]
  }
  positionRetentionWarningList(Object.assign({}, returnOrderForm.value, pageForm.value)).then(res => {
    const { data: { data } } = res
    ReturnTableData.value = data.list
    total.value = data.total
  })
}
// 采购账号
const createPurchaseCustomerDicTable = ref([])
const createPurchaseCustomerDicBtn = () => {
  createPurchaseCustomerDic().then(res => {
    const { data: { data } } = res
    createPurchaseCustomerDicTable.value = data
  })
}
const returnOrdertimes = ref([])
// 退货仓库
const returnWarehouse = ref([])
const createPurchaseWarehouseDicBtn = () => {
  createPurchaseWarehouseDic().then(res => {
    const { data: { data } } = res
    console.log('dataret')
    console.log(data)
    returnWarehouse.value = data
  })
}
// 待申请
const awaitGet = ref({ returnedApplyStatus: 0 })
const awaitGetSearch = () => {
  getList(Object.assign({}, awaitGet.value, pageForm.value))
}
const everyListContentForm = ref({})
const everyListContent = () => {
  getList(Object.assign({}, everyListContentForm.value, pageForm.value))
}
// 已申请，待上家同意
const topConsentForm = ref({ returnedApplyStatus: 1, processOrderStatus: 0 })
const topConsent = () => {
  getList(Object.assign({}, topConsentForm.value, pageForm.value))
}
// 上家同意,待取号
const awaitTakenumberForm = ref({ returnedApplyStatus: 1, trackingNumbersStatus: 0, processOrderStatus: 1 })
const awaitTakenumber = () => {
  getList(Object.assign({}, awaitTakenumberForm.value, pageForm.value))
}
// 上家同意待拣货
const topConsentFormGet = ref({ returnedApplyStatus: 1, processOrderStatus: 1, trackingNumbersStatus: 2, returnedPickStatus: 0 })
const topConsentAwait = () => {
  getList(Object.assign({}, topConsentFormGet.value, pageForm.value))
}
// 已拣货,待打包
const PickedAwaitPackForm = ref({ returnedApplyStatus: 1, returnedPickStatus: 2, returnedPackStatus: 0 })
const PickedAwaitPack = () => {
  getList(Object.assign({}, PickedAwaitPackForm.value, pageForm.value))
}
// 已打包待出库
const PackAwaitOutForm = ref({ returnedApplyStatus: 1, processOrderStatus: 1, trackingNumbersStatus: 2, returnedPickStatus: 1, returnedOutStatus: 0 })
const PackAwaitOut = () => {
  getList(Object.assign({}, PackAwaitOutForm.value, pageForm.value))
}
// 已出库
const deliveryForm = ref({ returnedApplyStatus: 1, processOrderStatus: 1, trackingNumbersStatus: 2, returnedPickStatus: 2, returnedOutStatus: 1 })
const delivery = () => {
  getList(Object.assign({}, deliveryForm.value, pageForm.value))
}
// 申请退货被上家拒绝
const returnRequestBeRejectedForm = ref({ returnedApplyStatus: 1, processOrderStatus: 2 })
const returnRequestBeRejected = () => {
  getList(Object.assign({}, returnRequestBeRejectedForm.value, pageForm.value))
}
// 发货后上家拒收
const deliverGoodsBeRejectedForm = ref({ returnedApplyStatus: 1, processOrderStatus: 3, handleStatus: 1 })
const deliverGoodsBeRejected = () => {
  getList(Object.assign({}, deliverGoodsBeRejectedForm.value, pageForm.value))
}
const notfindOrderForm = ref({ processOrderStatusRecognition: 0 })
const notfindOrderFormSearch = () => {
  getList(Object.assign({}, notfindOrderForm.value, pageForm.value))
}
// // 取号失败
// const SignFailureForm = ref({})
// const SignFailure = () => {
//   getList(Object.assign({}, deliverGoodsBeRejectedForm.value, pageForm.value))
// }
// 分页
const tableData = ref([])
const currentPage4 = ref(1)
const pageSize4 = ref(10)
const total = ref(0)
const handleSizeChange = (val) => {
  console.log(`${val} items per page`)
  pageForm.value.pageSize = val
  handleClick()
}
const handleCurrentChange = (val) => {
  console.log(`current page: ${val}`)
  pageForm.value.pageNum = val
  handleClick()
}
// 申请退货
const aReturnRequest = (row) => {
  productPurchaseReturnedApplyPurchaseReturned({
    productPurchaseReturnedIds: [row.id]
  }).then(res => {
    const { data: { data } } = res
    console.log(`cg://purchase?mode=afterSales&oid=${data}&ordersn=${row.productPurchaseOrderCode}&platform=${row.purchasePlatformId}&btntype=0&systype=newSystem`)
    location.href = `cg://purchase?mode=afterSales&oid=${data}&ordersn=${row.productPurchaseOrderCode}&platform=${row.purchasePlatformId}&btntype=0&systype=newSystem`
    handleClick()
  })
}
const OneApplication = () => {
  if (multipleSelection.value.length > 0) {
    multipleSelection.value.forEach(element => {
      aReturnRequest(element)
    })
  } else {
    ElMessage.error('选择数据')
  }
}
// 打印拣货单
// const getPrePickOrderDetailList = ref([])
const getPrePickOrderDetailBtn = (row) => {
  if (Object.prototype.toString.call(row) === '[object Object]') {
    productPurchaseReturnedPrintPurchaseReturned(row.id).then(res => {
      const { data: { data } } = res
      const valContent = JSON.parse(data.returnedPickWarehouseLocation).warehouseLocationData[0]
      console.log('valContent')
      console.log(valContent)
      const a = {
        orderOid: data.productPurchaseOrderCode,
        warehouseLocationName: valContent.name,
        orderNum: valContent.returnedNum,
        orderSkuPropertiesName: valContent.skuInfo
      }
      // getPrePickOrderDetailList.value = data
      if (localStorage.getItem('PrinterSetListKW')) {
        const lists = JSON.parse(localStorage.getItem('PrinterSetListKW'))
        const val = { cmd: 'print', requestID: '123458976', version: '1.0', task: { taskID: (new Date().getTime() + ''), preview: false, printer: lists[0].PrinterList, notifyMode: 'allInOne', previewType: 'pdf', documents: [{ documentID: '0123456789', contents: [{ data: { width: '65', height: '42', padding: '2', barcodeHeight: '8', barcodeMargin: '1.8', fontSize: '8', showOrderName: '0', left: '2', datas: a }, templateURL: 'http://yitaoweb.sc.kuaidi600.com/moban/TagMy.xml' }] }] } }
        store.socket.send(JSON.stringify(val))
        topConsentAwait()
        PackAwaitOut()
        // TagdialogVisible.value = false
      } else {
        ElMessage.success('先设置打印机')
      }
      // if (localStorage.getItem('PrinterSetListJH')) {
      //   const lists = JSON.parse(localStorage.getItem('PrinterSetListJH'))
      //   const val = { cmd: 'print', requestID: '123458976', version: '1.0', task: { taskID: (new Date().getTime() + ''), preview: false, printer: lists[0].PrinterList, notifyMode: 'allInOne', previewType: 'pdf', documents: [{ documentID: '0123456789', contents: [{ data: { width: '210', height: '297', padding: '2', fontSize: '8', left: '2', skuInfo: data.pdaCode, contens: JSON.parse(data.returnedPickWarehouseLocation).warehouseLocationData, trackingNumbers: data.trackingNumbers, barcodeHeight: '13' }, templateURL: 'http://yitaoweb.sc.kuaidi600.com/moban/A4JH.xml' }] }] } }
      //   store.socket.send(JSON.stringify(val))
      //   console.log(val)
      //
      // } else {
      //   ElMessage.error('先设置打印机')
      // }
    })
  } else if (Object.prototype.toString.call(row) === '[object Array]') {
    let b = 1
    if (row.length > 0) {
      row.forEach(e => {
        b++
        productPurchaseReturnedPrintPurchaseReturned(e.id).then(res => {
          const { data: { data } } = res
          const valContent = JSON.parse(data.returnedPickWarehouseLocation).warehouseLocationData[0]
          console.log('valContent')
          console.log(valContent)
          const a = {
            orderOid: data.productPurchaseOrderCode,
            warehouseLocationName: valContent.name,
            orderNum: valContent.returnedNum,
            orderSkuPropertiesName: valContent.skuInfo
          }
          if (localStorage.getItem('PrinterSetListKW')) {
            const lists = JSON.parse(localStorage.getItem('PrinterSetListKW'))
            const val = { cmd: 'print', requestID: '123458976', version: '1.0', task: { taskID: (new Date().getTime() + b), preview: false, printer: lists[0].PrinterList, notifyMode: 'allInOne', previewType: 'pdf', documents: [{ documentID: '0123456789', contents: [{ data: { width: '65', height: '42', padding: '2', barcodeHeight: '8', barcodeMargin: '1.8', fontSize: '8', showOrderName: '0', left: '2', datas: a }, templateURL: 'http://yitaoweb.sc.kuaidi600.com/moban/TagMy.xml' }] }] } }
            store.socket.send(JSON.stringify(val))
            topConsentAwait()
            PackAwaitOut()
          } else {
            ElMessage.success('先设置打印机')
          }
        })
      })
    } else {
      ElMessage.error('请先选择数据')
    }
  }
  // router.push({ path: '/home/getPrePickOrderDetail', query: { id: 1, name: '打印' } })
}
onMounted(() => {
  doConnect()
  handleClick()
})
const doConnect = () => {
  console.log('d打开了不')
  store.socket = new WebSocket('ws://localhost:13528')
  // 打开Socket
  store.socket.onopen = function (event) {
    // 监听消息
    store.socket.onmessage = function (event) {
      // localStorage.setItem('printerproperties', event.data)
    }
    // 监听Socket的关闭
    store.socket.onclose = function (event) {
      // console.log('Client notified socket has closed', event)
    }
  }
}
// 销毁
onBeforeUnmount(() => {
  console.log('销毁')
  store.destroyed()
})

// const PackingComplete = (row) => {
//   productPurchaseReturnedPackPurchaseReturned({
//     productPurchaseReturnedIds: [...row.id]
//   }).then(res => {
//     ElMessage.success('操作成功')
//     PickedAwaitPack()
//   })
// }
// const batchPackingComplete = () => {
//   const ids = []
//   if (multipleSelection.value.length > 0) {
//     multipleSelection.value.forEach(element => {
//       ids.push(element.id)
//     })
//     PackingComplete(ids)
//     PickedAwaitPack()
//   } else {
//     ElMessage.error('选择数据')
//   }
// }
// const outHouse = (row) => {
//   productPurchaseReturnedOutPurchaseReturned({
//     productPurchaseReturnedIds: [...row.id]
//   }).then(res => {
//     ElMessage.success('操作成功')
//     PackAwaitOut()
//   })
// }

// const batchOutHouse = () => {
//   const ids = []
//   if (multipleSelection.value.length > 0) {
//     multipleSelection.value.forEach(element => {
//       ids.push(element.id)
//     })
//     outHouse(ids)
//     PackAwaitOut()
//   } else {
//     ElMessage.error('选择数据')
//   }
// }
// const productPurchaseReturnedpurchaseReturnedWaybillCodeBtn = (row) => {
//   productPurchaseReturnedpurchaseReturnedWaybillCode({
//     productPurchaseReturnedIds: [...row.id]
//   }).then(res => {
//     ElMessage.success('操作成功')
//     topConsentAwait()
//   })
// }

const createReturnNumdialogVisible = ref(false)
const createReturnSucc = (row) => {
  createReturnNumsForm.value.productPurchaseStorageId = row.productPurchaseStorageId
  createReturnNumdialogVisible.value = true
}
const createReturnNumsForm = ref({
  productPurchaseStorageId: 0,
  returnedNum: 0
})
const createReturnNumdialogVisibleSubmit = () => {
  productPurchaseReturnedCreatePurchaseReturned(createReturnNumsForm.value).then(res => {
    ElMessage.success('操作成功')
    createReturnNumdialogVisible.value = false
  })
}
const nowKw = ref([])
const getKwNow = (row) => {
  nowKw.value = []
  nowKw.value = row
}
const FailureSearchForm = ref({})
const FailureSearch = () => {
  waybillcodelist(Object.assign({}, FailureSearchForm.value, pageForm.value)).then(res => {
    console.log(res)
    const { data: { data } } = res
    total.value = data.total
    tableData.value = data.list
  })
}
const listReturnedWaybillCodeFailMsgDicForm = ref({})
const listReturnedWaybillCodeFailMsgDicApi = () => {
  listReturnedWaybillCodeFailMsgDic().then(res => {
    const { data: { data } } = res
    listReturnedWaybillCodeFailMsgDicForm.value = data
  })
}
const retlowSerDialogVisible = ref(false)
const rowNowContent = ref({})
const fatherProductPurchaseOrderCode = ref('')
const ExchangeExpress = (row) => {
  fatherProductPurchaseOrderCode.value = row.productPurchaseOrderCode
  retlowSerDialogVisible.value = true
  productPurchaseReturnedWaybillcode(row.productPurchaseOrderCode).then(res => {
    const { data: { data } } = res
    rowNowContent.value = data
  })
}
const expressNow = ref('')
const submitExpress = () => {
  waybillcodechangeExpress(fatherProductPurchaseOrderCode.value, expressNow.value).then(res => {
    ElMessage.success('操作成功')
    retlowSerDialogVisible.value = false
    FailureSearch()
  })
}

const fourthactiveName = ref('fourthfirst')
const changefourthactiveName = (tab) => {
  if (tab) {
    console.log('tab.props.name')
    console.log(tab.props)
    fourthactiveName.value = tab.props ? tab.props.name : fourthactiveName.value
  }
  if (fourthactiveName.value === 'fourthfirst') {
    deliverGoodsBeRejectedForm.value.handleStatus = 1
    deliverGoodsBeRejected()
  }
  if (fourthactiveName.value === 'fourthsecond') {
    deliverGoodsBeRejectedForm.value.handleStatus = 2
    deliverGoodsBeRejected()
  }
  if (fourthactiveName.value === 'fourththird') {
    deliverGoodsBeRejectedForm.value.handleStatus = 3
    deliverGoodsBeRejected()
  }
  if (fourthactiveName.value === 'fourthfourth') {
    deliverGoodsBeRejectedForm.value.handleStatus = 4
    deliverGoodsBeRejected()
  }
}
// 标记
const markingdialogVisibleType = ref([])
const markingdialogVisible = ref(false)
const listReturnedMarkInfoDicBtn = () => {
  listReturnedMarkInfoDic().then(res => {
    markingdialogVisible.value = true
    const { data: { data } } = res
    markingdialogVisibleType.value = data
  })
}
const markingRowId = ref('')
const markingOne = (row) => {
  markingRowId.value = row.id
  listReturnedMarkInfoDicBtn()
}
const TypeMarking = ref('')
const submitmarking = () => {
  returnedMarkInfomake({ returnedMarkInfo: TypeMarking.value }, markingRowId.value).then(res => {
    ElMessage.success('操作成功')
    changefourthactiveName()
    markingdialogVisible.value = false
  })
}
// 不可处理
const noMarking = (row) => {
  returnedHandleCannot(row.id).then(res => {
    ElMessage.success('操作成功')
    changefourthactiveName()
  })
}
const returnedHandleCannotVerifycancelBtn = (row) => {
  returnedHandleCannotVerifycancel(row.id).then(res => {
    ElMessage.success('操作成功')
    changefourthactiveName()
  })
}
const returnedHandleCannotVerifypassBtn = (row) => {
  returnedHandleCannotVerifypass(row.id).then(res => {
    ElMessage.success('操作成功')
    changefourthactiveName()
  })
}
</script>

<style lang='less' scoped>
.demo-tabs>.el-tabs__content {
  padding: 32px;
  color: #6b778c;
  font-size: 32px;
  font-weight: 600;
}
</style>
